package com.meritit.product.spi;

import com.sun.portal.container.ChannelMode;
import com.sun.portal.container.ChannelState;
import com.sun.portal.container.ChannelURLType;
import com.sun.portal.container.WindowRequestReader;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

public class WindowRequestReaderImpl implements WindowRequestReader {

    @Override
    public ChannelMode readNewPortletWindowMode(HttpServletRequest request) {
        String mode = request.getParameter("newPortletWindowMode");
        return new ChannelMode(mode);
    }

    @Override
    public ChannelState readNewWindowState(HttpServletRequest request) {
        String state = request.getParameter("newWindowState");
        return new ChannelState(state);
    }

    @Override
    public ChannelURLType readURLType(HttpServletRequest request) {
        return new ChannelURLType(request.getParameter("channelURlType"));
    }

    @Override
    public Map<String, String[]> readParameterMap(HttpServletRequest request) {
        return (Map<String, String[]>) request.getAttribute("parameterMap");
    }

    @Override
    public String getCacheLevel(HttpServletRequest request) {
        return request.getParameter("cacheLevel");
    }

    @Override
    public String getResourceID(HttpServletRequest request) {
        return request.getParameter("resourceID");
    }
}
